from time import time

file1 = open('m1_sorted.txt').readlines()
file2 = open('m2_reverse.txt').readlines()
file3 = open('m3_shuffle.txt').readlines()
f1 = []
f2 = []
f3 = []
for i in range(len(file1)):
    f1.append(int(file1[i]))

for i in range(len(file2)):
    f2.append(int(file2[i]))
    
for i in range(len(file3)):
    f3.append(int(file3[i]))

t1 = time()
for i in range(len(f1) - 1):
    k = 0
    for j in range(len(f1) - i - 1):
        if f1[j] > f1[j+1]:
            f1[j], f1[j+1] = f1[j+1], f1[j]
            k += 1
    if k == 0:
        break
t2 = time()
time1 = int((t2 - t1) * 1000)

t1 = time()
for i in range(len(f2) - 1):
    k = 0
    for j in range(len(f2) - i - 1):
        if f2[j] > f2[j+1]:
            f2[j], f2[j+1] = f2[j+1], f2[j]
            k += 1
    if k == 0:
        break
t2 = time()
time2 = int((t2 - t1) * 1000)

t1 = time()
for i in range(len(f3) - 1):
    k = 0
    for j in range(len(f3) - i - 1):
        if f3[j] > f3[j+1]:
            f3[j], f3[j+1] = f3[j+1], f3[j]
            k += 1
    if k == 0:
        break
t2 = time()
time3 = int((t2 - t1) * 1000)
print('m1_sorted', time1, 'milliseconds')
print('m2_reverse', time2, 'milliseconds')
print('m3_shuffle', time3, 'milliseconds')
